package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_docker//container:image.bzl", "container_image")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("//prow:def.bzl", "prow_image")

NAME = "gcsweb"

container_image(
    name = "icons-base",
    base = "@alpine-base//image",
    directory = "/icons",
    files = [
        "//gcsweb:icons",
    ],
)

container_image(
    name = "assets-base",
    base = "icons-base",
    directory = "/styles",
    files = [
        "//gcsweb:styles",
    ],
)

prow_image(
    name = "image",
    base = ":assets-base",
    component = NAME,
    visibility = ["//visibility:public"],
)

go_binary(
    name = NAME,
    embed = [":go_default_library"],
    pure = "on",
)

go_library(
    name = "go_default_library",
    srcs = [
        "gcsweb.go",
        "templates.go",
    ],
    importpath = "k8s.io/test-infra/gcsweb/cmd/gcsweb",
    deps = [
        "//gcsweb/pkg/version:go_default_library",
        "//prow/logrusutil:go_default_library",
        "//prow/pjutil:go_default_library",
        "@com_github_sirupsen_logrus//:go_default_library",
        "@com_google_cloud_go_storage//:go_default_library",
        "@org_golang_google_api//iterator:go_default_library",
        "@org_golang_google_api//option:go_default_library",
    ],
)

filegroup(
    name = "package-srcs",
    srcs = glob(["**"]),
    tags = ["automanaged"],
    visibility = ["//visibility:private"],
)

filegroup(
    name = "all-srcs",
    srcs = [":package-srcs"],
    tags = ["automanaged"],
)

go_test(
    name = "go_default_test",
    srcs = ["gcsweb_test.go"],
    embed = [":go_default_library"],
    deps = [
        "@com_github_google_go_cmp//cmp:go_default_library",
        "@com_github_gorilla_mux//:go_default_library",
        "@com_google_cloud_go_storage//:go_default_library",
        "@org_golang_google_api//option:go_default_library",
    ],
)
